package com.evil.DAO;

import com.evil.Bean.LoopViewPagerBean;
import com.evil.DB_Utils.DB_Utils;
import com.evil.DB_Utils.QueryCallBack;

import java.util.ArrayList;

/********************************************
 * 工程名：Web
 * 包名：com.evil.DAO
 * 时间：16-9-12 下午1:15
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：首页广告轮询DAO
 ********************************************/
public class LoopViewPagerDAO
{
    private ArrayList<LoopViewPagerBean> loopViewPagerBeanArrayList;


    /**
     * 查询全部
     * @return 返回Bean数组
     */
    public ArrayList<LoopViewPagerBean> findAll()
    {
        String url = "SELECT\n" +
                "loop_viewpager.id,\n" +
                "loop_viewpager.imgRes,\n" +
                "loop_viewpager.`desc`,\n" +
                "loop_viewpager.url,\n" +
                "loop_viewpager.intent,\n" +
                "loop_viewpager.datetime,\n" +
                "loop_viewpager.`enable`\n" +
                "FROM\n" +
                "loop_viewpager";

        loopViewPagerBeanArrayList = new ArrayList<>();

        DB_Utils.query(url).build().getAll(new QueryCallBack()
        {
            @Override
            public void onCallBack(Next next)
            {
                LoopViewPagerBean bean = new LoopViewPagerBean();
                bean.setId(next.getInt(1));
                bean.setImgRes(next.getString(2));
                bean.setDesc(next.getString(3));
                bean.setUrl(next.getString(4));
                bean.setIntent(next.getString(5));
                bean.setDatetime(next.getDateTime(6));
                bean.setEnable(next.getInt(7) == 1);
                loopViewPagerBeanArrayList.add(bean);
            }
        });

        return loopViewPagerBeanArrayList;
    }
}


















